import static org.junit.Assert.*;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Scanner;

import org.junit.Before;
import org.junit.Test;

public class MainTest1 {

	

	@Test
	public void test() {
		String fileName = "d:/Test.data";
	    int count = 1000*10000;
	    PrintWriter pw = null;
	    try {
	        pw = new PrintWriter(fileName);

	        for (int i = 0; i < count; i++) {
	            pw.print(1);
	        }

	    } catch (FileNotFoundException e) {
	        e.printStackTrace();
	    }finally{
	        pw.close();
	    }
	}
	@Test
	public void BufferedReaderTest(){
		String fileName = "d:/Test.data";
		BufferedReader br=null;
		try {
			 br = new BufferedReader(new FileReader(fileName));
			while(br.readLine()!=null){};//只是读出，不进行任何处理
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}finally{
			try {
				br.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}

	}
	 @Test
	   public void ScannerTest(){
		 String fileName = "d:/Test.data";
		 Scanner sc=null;
		 try {
			sc=new Scanner(new FileReader(fileName));
			while(sc.hasNextLine()){
				
			}
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		 finally{
			 sc.close();
		 }
	    }
}
  
